Repository navigation
Phase 2: smarter AI (router, filter-aware SQL, self-repair, streaming steps, eval) - #8
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Average temperature at different depths in the Arabian Sea" used to run a whole-ocean template. Templates now join profiles and take the question's region/month/year/sensor filters as bound parameters (regional comparisons keep every region), and the answer title names the filters. Search and SQL share one filter validator, so invalid values are dropped everywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- floatchat/router.py: the LLM returns a JSON route (path, intent, filters,
standalone question), validated against the known intents and filters;
the keyword router takes over when there is no LLM or its reply is
unusable, and resolves cue-word follow-ups ("now only the Arabian Sea")
- llm.chat: JSON mode, one retry on HTTP 429 honouring Retry-After (max 10 s)
- llm.chat_stream: yields the answer text as the LLM writes it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Custom SQL that fails is sent back to the LLM with the database's error message, up to 2 repairs; each attempt is reported as a step. Filters are passed to the LLM when it writes custom SQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- answer_question routes through the LLM/keyword router, reports each step (understood, sql attempts, search, answer) and streams the answer text - /query accepts up to 3 history turns for follow-ups and returns intent, filters and steps; follow-up answers are not cached - POST /query/stream sends step, token and result events (Server-Sent Events); cached answers replay their steps; same rate limits as /query Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat now sends the last three answered turns so questions like "now only the Arabian Sea" keep the earlier analysis, and every answer has a "How I answered" expander listing the router decision, SQL attempts, search matches and whether the LLM wrote the text. Example dates now match the rolling 12-month dataset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eval/questions.json holds 30 benchmark questions (every analysis, region, month/year, sensor, descriptive search and follow-up). python -m eval --api <url> asks them with rate-limit pacing and scores routing, filter accuracy and answer checks (SQL rows that really apply the filters; searched profiles that match them), writing eval/latest.md and eval/latest.json. A weekly workflow runs it against the live API. The README documents Phase 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of the showcase plan: FloatChat now understands questions better, fixes its own SQL, and shows how it reached each answer.
What's new
floatchat/filters.py) and always passed as bound parameters.floatchat/router.py). The LLM reads free phrasing and follow-ups ("now only the Bay of Bengal") and replies in JSON, which is validated. Keyword rules take over when the LLM is unavailable or its reply is unusable.Retry-After(waits capped at 10 s).steps: what was understood, each SQL attempt, the search, and who wrote the text. The newPOST /query/streamendpoint sends them as Server-Sent Events (step,token,result,error), ready for the Phase 3 web app.eval/). 30 benchmark questions, scored on routing, filters and answer checks, viapython -m eval --api <url>. A weekly workflow runs it against the live API./queryis backward compatible:history(request) andfilters/steps(response) are optional additions.Testing
🤖 Generated with Claude Code